import requests
#封装 tpshop 商城 接口对象层
class TpshopLoginApi(object):
    #获取验证码
    @classmethod
    def get_verify(cls,session):
        session.get(url="https://hmshop-test.itheima.net/index.php?m=Home&c=User&a=verify&r=0.24617996152873056")

    #登录
    @classmethod
    def login(cls,session,login_data):
        resp = session.post(url="https://hmshop-test.itheima.net/index.php?"
                                "m=Home&c=User&a=do_login&t=0.4793513696843317",data=login_data)
        return resp

# 测试，自己封装的接口，功能是否正常！
if __name__ == '__main__':
    session = requests.Session()
    # 发送获取验证码请求
    TpshopLoginApi.get_verify(session)

    login_data = {"username": "13600001111", "password": "123456", "verify_code": "8888"}
    # 发送登录请求
    response = TpshopLoginApi.login(session, login_data)

    print("登录结果：", response.json())